package com.wish.wishhouses_market.controller;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wish.wishhouses_market.service.*;

import dto.housesMarketDto.PremisesDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import vo.ResultEntity;

import java.util.List;

/**
 * <p>
 * 楼盘信息表 前端控制器
 * </p>
 *
 * @author fanzijun
 * @since 2021-03-31
 */
@RestController
@RequestMapping("/tbPremisesInfo")
public class TbPremisesInfoController {

    @Autowired
    ITbPremisesInfoService iTbPremisesInfoService;
    @Autowired
    ITbBusinessCircleService iTbBusinessCircleService;
    @Autowired
    ISysRegionService iSysRegionService;
    @Autowired
    ITbSubwayService iTbSubwayService;
    @Autowired
    ITbConfigPremisesPropertyService iTbConfigPremisesPropertyService;
    /**
     * 列表
     */
    @RequestMapping("/list")
    public ResultEntity list(PremisesDto premisesDto){
        PageHelper.startPage(premisesDto.getPageNum(),premisesDto.getPageSize());
        //查询列表数据
        List list = iTbPremisesInfoService.getList(premisesDto);
        PageInfo<Object> pageInfo = new PageInfo<>(list);
        return ResultEntity.ok("200","查询成功",pageInfo);
    }
    /**
     * 获取楼盘特色列表
     */
    @RequestMapping("/getPropertyList")
    public ResultEntity getPropertyList(){
        List list = iTbConfigPremisesPropertyService.list();
        return ResultEntity.ok("200","查询成功",list);
    }
    /**
     * 保存
     */
    @RequestMapping("/save")
    public ResultEntity save(@RequestBody PremisesDto premisesDto) {

        iTbPremisesInfoService.save(premisesDto);

        return ResultEntity.ok("200","保存成功");
    }
    /**
     * 查询回显
     */
    @RequestMapping("/getbyid")
    public ResultEntity getDatabyid(Integer id){
        PremisesDto premisesInfos= iTbPremisesInfoService.FindByid(id);
        return ResultEntity.ok("200","查询成功",premisesInfos);
    }
}

